import 'dart:convert';

class ApiResponse {
  final Data? data;
  final String? message;
  final int? code;

  ApiResponse({
    this.data,
    this.message,
    this.code,
  });

  // Factory method to create ApiResponse from JSON
  factory ApiResponse.fromJson(Map<String, dynamic> json) {
    return ApiResponse(
      data: json['data'] != null ? Data.fromJson(json['data']) : null,
      message: json['message'],
      code: json['code'],
    );
  }
}

class Data {
  final String? userId;
  final String? companyId;
  final String? qrCode;

  Data({
    this.userId,
    this.companyId,
    this.qrCode,
  });

  // Factory method to create Data from JSON
  factory Data.fromJson(Map<String, dynamic> json) {
    return Data(
      userId: json['userId'],
      companyId: json['companyId'],
      qrCode: json['qrCode'],
    );
  }

  // 重写 toString() 方法
  @override
  String toString() {
    return 'Data(userId: $userId, companyId: $companyId, qrCode: $qrCode)';
  }
}
